{any_include file="scp_page_start.tpl" wide=1}

<!-- $Id$ -->

<h1>OAuth - {if $consumer.id}Update{else}Request{/if} Consumer Key &amp; Secret</h1>

{any_include file="scp_oauth_menu.tpl"}

<p>When you want to talk with our API, then you will need a consumer key and secret.  Here you can request one.</p>

<form action="{$rel_path}module/OAuth/server/register" method="POST">

{if $consumer}
<fieldset>
	<legend>Consumer Key And Secret</legend>
	<dl>
		<dt>Consumer Key</dt>
		<dd><h3>{$consumer.consumer_key|escape}</h3></dd>
		<dt>Consumer Secret</dt>
		<dd><h3>{$consumer.consumer_secret|escape}</h3></dd>
	</dl>
</fieldset>

<input type="hidden" name="id"              value="{$consumer.id|escape}" />
<input type="hidden" name="consumer_key"    value="{$consumer.consumer_key|escape}" />
<input type="hidden" name="consumer_secret" value="{$consumer.consumer_secret|escape}" />
{/if}

<fieldset>
	<legend>About You</legend>

	<p>
		<label for="requester_name">Your name</label><br/>
		<input class="text" id="requester_name"  name="requester_name" type="text" value="{if $consumer}{$consumer.requester_name|escape}{else}{any_member show="name"}{/if}" />
	</p>

	<p>
		<label for="requester_email">Your email address</label><br/>
		<input class="text" id="requester_email"  name="requester_email" type="text" value="{if $consumer}{$consumer.requester_email|escape}{else}{any_member show="email"}{/if}" />
	</p>
</fieldset>

<fieldset>
	<legend>About Your Application Or Site</legend>

	<p>
		<label for="application_title">Title of your application or site</label><br/>
		<input class="text" id="application_title" name="application_title" type="text" value="{$consumer.application_title|escape}" />
	</p>
	
	<p>
		<label for="application_descr">Describe your application or site (visible for users)</label><br/>
		<textarea id="application_descr" name="application_descr">{$consumer.application_descr|escape}</textarea>
	</p>
	
	<p>
		<label for="application_notes">Notes (for our internal use)</label><br/>
		<textarea id="application_notes" name="application_notes">{$consumer.application_notes|escape}</textarea>
	</p>
</fieldset>

<fieldset>
	<legend>Location Of Your Application Or Site</legend>

	<p>
		<label for="application_uri">URL of your application or site</label><br/>
		<input id="application_uri" class="text" name="application_uri" type="text" value="{$consumer.application_uri|escape}" />
	</p>

	<p>
		<label for="callback_uri">Callback URL</label><br/>
		<input id="callback_uri" class="text" name="callback_uri" type="text" value="{$consumer.callback_uri|escape}" />
	</p>
</fieldset>

<fieldset>
	<legend>How You Use The Key</legend>

	<p>
		<input type="radio" class="radio" name="application_commercial" value="0" {if empty($consumer.application_commercial)}checked="checked"{/if} /> Non-commercial use<br/>
		<input type="radio" class="radio" name="application_commercial" value="1" {if !empty($consumer.application_commercial)}checked="checked"{/if} /> Commercial use
	</p>
</fieldset>

<!-- TODO: add some checkbox regarding legal use etc. of our APIs -->

<fieldset class="submit">
	<p>

		<button type="submit">
			{if $consumer.id}Update Key{else}Request Key{/if}
		</button>

		<a class="button" href="{$rel_path}module/OAuth/server/delete?consumer_key={$consumer.consumer_key|escape:"url"}">
			Delete Server
		</a>

		<a class="button" href="{$rel_path}module/OAuth/server/list">
			Cancel
		</a>
	</p>
</fieldset>

</form>

{any_include file="scp_page_end.tpl" wide=1}
